#pragma once

#include "socket.h"
#include "Logger.h"
#include <cctype>
#include <dirent.h>
#include <direct.h>
#include <sys/stat.h>
#include <time.h>
#include <fstream>
#include <sstream>

class Server
{
public:
	Server(int port);
	virtual ~Server(void);
	//Functions
	void start();

private:
	//Fields
	ServerSocket *serverSocket;
	char* ROOT;
	//Functions
	void createWebroot();
	void createSubDirs(char *filename);
	bool hasAccess(Socket *socket, char *filename);
	void parseCommands(Socket *socket);
	void processCommand(Socket *socket, char *cmd, char *arg1, char *arg2);
	void processDIRCommand(Socket *socket, char *dirName);
	void processRENCommand(Socket *socket, char *currentFilename, char *newFilename);
	void processDELCommand(Socket *socket, char *filename);
	void processGETCommand(Socket *socket, char *filename);
	void processPUTCommand(Socket *socket, char *filename, char* fileSize);
};

